﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:Ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary">
	<Style TargetType="Ribbon:RibbonMenuButton">
		<Setter Property="BorderThickness" Value="1" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Ribbon:RibbonMenuButton}">
					<Grid x:Name="MainGrid" SnapsToDevicePixels="True">
						<Grid.ColumnDefinitions>
							<ColumnDefinition />
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>
						<Ribbon:RibbonToggleButton x:Name="PART_ToggleButton"
								BorderBrush="{TemplateBinding BorderBrush}"
								BorderThickness="{TemplateBinding BorderThickness}"
								Background="{TemplateBinding Background}"
								CheckedBackground="{TemplateBinding PressedBackground}" ClickMode="Press"
								ControlSizeDefinition="{TemplateBinding ControlSizeDefinition}"
								CheckedBorderBrush="{TemplateBinding PressedBorderBrush}"
								FocusedBackground="{TemplateBinding FocusedBackground}"
								FocusedBorderBrush="{TemplateBinding FocusedBorderBrush}" FocusVisualStyle="{x:Null}"
								HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
								IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
								Label="{TemplateBinding Label}" LargeImageSource="{TemplateBinding LargeImageSource}"
								MouseOverBackground="{TemplateBinding MouseOverBackground}"
								MouseOverBorderBrush="{TemplateBinding MouseOverBorderBrush}"
								Padding="{TemplateBinding Padding}"
								Ribbon:RibbonTwoLineText.PathData="{TemplateBinding Ribbon:RibbonTwoLineText.PathData}"
								Style="{x:Null}" SmallImageSource="{TemplateBinding SmallImageSource}">
							<Ribbon:RibbonToggleButton.Template>
								<ControlTemplate TargetType="{x:Type Ribbon:RibbonToggleButton}">
									<Border x:Name="OuterBorder" BorderBrush="{TemplateBinding BorderBrush}"
											BorderThickness="{TemplateBinding BorderThickness}"
											Background="{TemplateBinding Background}" SnapsToDevicePixels="True"
											Padding="{TemplateBinding Padding}">
										<StackPanel x:Name="StackPanel" IsHitTestVisible="False">
											<Image x:Name="PART_Image" RenderOptions.BitmapScalingMode="NearestNeighbor"
													HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
													Height="32" Margin="0,6,0,0"
													Source="{TemplateBinding LargeImageSource}"
													VerticalAlignment="Center" Width="32" />
											<Ribbon:RibbonTwoLineText x:Name="TwoLineText" HorizontalAlignment="Center"
													LineStackingStrategy="BlockLineHeight" LineHeight="13"
													Margin="1,1,1,0" TextAlignment="Center"
													Text="{TemplateBinding Label}" VerticalAlignment="Top"
													PathFill="{TemplateBinding Foreground}"
													Ribbon:RibbonTwoLineText.HasTwoLines="{TemplateBinding Ribbon:RibbonTwoLineText.HasTwoLines}"
													Ribbon:RibbonTwoLineText.PathData="{TemplateBinding Ribbon:RibbonTwoLineText.PathData}" />
										</StackPanel>
									</Border>
									<ControlTemplate.Triggers>
										<DataTrigger
												Binding="{Binding ControlSizeDefinition.ImageSize, RelativeSource={RelativeSource Self}}"
												Value="Large">
											<Setter Property="MinWidth" Value="42" />
											<Setter Property="Height" Value="69" />
											<Setter Property="MinHeight" TargetName="TwoLineText" Value="26" />
											<Setter Property="Ribbon:RibbonTwoLineText.HasTwoLines"
													TargetName="TwoLineText" Value="True" />
										</DataTrigger>
										<DataTrigger
												Binding="{Binding ControlSizeDefinition.ImageSize, RelativeSource={RelativeSource Self}}"
												Value="Small">
											<Setter Property="Height" Value="22" />
											<Setter Property="Margin" TargetName="PART_Image" Value="1,0" />
											<Setter Property="Source" TargetName="PART_Image"
													Value="{Binding SmallImageSource, RelativeSource={RelativeSource TemplatedParent}}" />
											<Setter Property="Width" TargetName="PART_Image" Value="16" />
											<Setter Property="Height" TargetName="PART_Image" Value="16" />
											<Setter Property="HorizontalAlignment" TargetName="TwoLineText" Value="Left" />
											<Setter Property="VerticalAlignment" TargetName="TwoLineText" Value="Center" />
											<Setter Property="VerticalAlignment" TargetName="PART_Image" Value="Center" />
											<Setter Property="Margin" TargetName="TwoLineText" Value="1" />
											<Setter Property="Orientation" TargetName="StackPanel" Value="Horizontal" />
										</DataTrigger>
										<MultiDataTrigger>
											<MultiDataTrigger.Conditions>
												<Condition
														Binding="{Binding ControlSizeDefinition.ImageSize, RelativeSource={RelativeSource Self}}"
														Value="Small" />
												<Condition
														Binding="{Binding IsInQuickAccessToolBar, RelativeSource={RelativeSource Self}}"
														Value="True" />
											</MultiDataTrigger.Conditions>
											<Setter Property="Height" Value="Auto" />
										</MultiDataTrigger>
										<DataTrigger
												Binding="{Binding ControlSizeDefinition.IsLabelVisible, RelativeSource={RelativeSource Self}}"
												Value="False">
											<Setter Property="Text" TargetName="TwoLineText" Value="{x:Null}" />
											<Setter Property="Margin" TargetName="TwoLineText" Value="0" />
										</DataTrigger>
										<DataTrigger
												Binding="{Binding ControlSizeDefinition.ImageSize, RelativeSource={RelativeSource Self}}"
												Value="Collapsed">
											<Setter Property="Visibility" TargetName="PART_Image" Value="Collapsed" />
										</DataTrigger>
										<Trigger Property="IsMouseOver" Value="True">
											<Setter Property="Background" TargetName="OuterBorder"
													Value="{Binding MouseOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
											<Setter Property="BorderBrush" TargetName="OuterBorder"
													Value="{Binding MouseOverBorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</Trigger>
										<Trigger Property="IsKeyboardFocused" Value="True">
											<Setter Property="Background" TargetName="OuterBorder"
													Value="{Binding FocusedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
											<Setter Property="BorderBrush" TargetName="OuterBorder"
													Value="{Binding FocusedBorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</Trigger>
										<Trigger Property="IsEnabled" Value="False">
											<Setter Property="Opacity" TargetName="PART_Image" Value="0.5" />
											<Setter Property="TextElement.Foreground" TargetName="OuterBorder"
													Value="#FF9E9E9E" />
											<Setter Property="PathFill" TargetName="TwoLineText" Value="#FF9E9E9E" />
										</Trigger>
										<Trigger Property="IsChecked" Value="True">
											<Setter Property="Background" TargetName="OuterBorder"
													Value="{Binding CheckedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
											<Setter Property="BorderBrush" TargetName="OuterBorder"
													Value="{Binding CheckedBorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</Trigger>
										<Trigger Property="IsPressed" Value="True">
											<Setter Property="Background" TargetName="OuterBorder"
													Value="{Binding PressedBackground, RelativeSource={RelativeSource TemplatedParent}}" />
											<Setter Property="BorderBrush" TargetName="OuterBorder"
													Value="{Binding PressedBorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</Trigger>
										<Trigger Property="IsInControlGroup" Value="True">
											<Setter Property="BorderBrush" TargetName="OuterBorder"
													Value="{Binding Ribbon.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}" />
											<Setter Property="BorderThickness" TargetName="OuterBorder" Value="0,0,1,0" />
										</Trigger>
									</ControlTemplate.Triggers>
								</ControlTemplate>
							</Ribbon:RibbonToggleButton.Template>
						</Ribbon:RibbonToggleButton>
						<Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="False"
								IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
								Placement="Bottom" PopupAnimation="Fade" HorizontalOffset="-5" VerticalOffset="-5">
							<Popup.CacheMode>
								<BitmapCache />
							</Popup.CacheMode>
							<Popup.Style>
								<Style TargetType="Popup">
									<Style.Triggers>
										<Trigger Property="IsOpen" Value="True">
											<Trigger.EnterActions>
												<BeginStoryboard>
													<Storyboard>
														<DoubleAnimation Storyboard.TargetProperty="VerticalOffset"
																From="-30" Duration="0:0:0.4">
															<DoubleAnimation.EasingFunction>
																<QuarticEase />
															</DoubleAnimation.EasingFunction>
														</DoubleAnimation>
													</Storyboard>
												</BeginStoryboard>
											</Trigger.EnterActions>
										</Trigger>
									</Style.Triggers>
								</Style>
							</Popup.Style>
							<Border>
								<Border.CacheMode>
									<BitmapCache />
								</Border.CacheMode>
								<Border.Effect>
									<DropShadowEffect Color="#FFBBBBBB" ShadowDepth="0" RenderingBias="Performance"
											Opacity="0.5" />
								</Border.Effect>
								<Border x:Name="MenuBorder" Margin="5"
										BorderBrush="{Binding Ribbon.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
										BorderThickness="{TemplateBinding BorderThickness}"
										Background="{DynamicResource White}">
									<Grid>
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition />
											<RowDefinition Height="Auto" />
										</Grid.RowDefinitions>
										<ScrollViewer x:Name="PART_SubMenuScrollViewer" Margin="1" Grid.Row="1"
												Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
											<Grid RenderOptions.ClearTypeHint="Enabled">
												<Canvas x:Name="BackgroundCanvas" HorizontalAlignment="Left" Height="0"
														VerticalAlignment="Top" Width="0">
													<Rectangle x:Name="OpaqueRect"
															Fill="{Binding Background, ElementName=MenuBorder}"
															Height="{Binding ActualHeight, ElementName=MenuBorder}"
															Width="{Binding ActualWidth, ElementName=MenuBorder}" />
												</Canvas>
												<ItemsPresenter x:Name="ItemsPresenter"
														KeyboardNavigation.DirectionalNavigation="Cycle"
														Grid.IsSharedSizeScope="True"
														KeyboardNavigation.TabNavigation="Cycle" />
											</Grid>
										</ScrollViewer>
										<Border x:Name="ResizeControl"
												BorderBrush="{Binding Ribbon.BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
												BorderThickness="0,1,0,0" Background="#FFE5EFF9" Grid.Row="2"
												Visibility="Collapsed">
											<Thumb x:Name="PART_ResizeThumb">
												<Thumb.Style>
													<Style TargetType="{x:Type Thumb}">
														<Setter Property="Width" Value="11" />
														<Setter Property="Height" Value="11" />
														<Setter Property="VerticalAlignment" Value="Bottom" />
														<Setter Property="HorizontalAlignment" Value="Right" />
														<Setter Property="Cursor" Value="SizeNWSE" />
														<Setter Property="Template">
															<Setter.Value>
																<ControlTemplate TargetType="{x:Type Thumb}">
																	<Border Background="Transparent">
																		<Path
																				Data="M9,0L11,0 11,11 0,11 0,9 3,9 3,6 6,6 6,3 9,3z"
																				Margin="0,0,2,2">
																			<Path.Fill>
																				<DrawingBrush TileMode="Tile"
																						Viewbox="0,0,3,3"
																						Viewport="0,0,3,3"
																						ViewportUnits="Absolute"
																						ViewboxUnits="Absolute">
																					<DrawingBrush.Drawing>
																						<DrawingGroup>
																							<GeometryDrawing
																									Brush="#FF6C747D"
																									Geometry="M0,0L2,0 2,2 0,2z" />
																						</DrawingGroup>
																					</DrawingBrush.Drawing>
																				</DrawingBrush>
																			</Path.Fill>
																		</Path>
																	</Border>
																</ControlTemplate>
															</Setter.Value>
														</Setter>
														<Style.Triggers>
															<Trigger Property="FlowDirection" Value="RightToLeft">
																<Setter Property="Cursor" Value="SizeNESW" />
															</Trigger>
														</Style.Triggers>
													</Style>
												</Thumb.Style>
											</Thumb>
										</Border>
									</Grid>
								</Border>
							</Border>
						</Popup>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="CanContentScroll" SourceName="PART_SubMenuScrollViewer" Value="False">
							<Setter Property="Canvas.Top" TargetName="OpaqueRect"
									Value="{Binding VerticalOffset, ElementName=PART_SubMenuScrollViewer}" />
							<Setter Property="Canvas.Left" TargetName="OpaqueRect"
									Value="{Binding HorizontalOffset, ElementName=PART_SubMenuScrollViewer}" />
							<!--<Setter Property="Canvas.Top" TargetName="OverlayRect"
									Value="{Binding VerticalOffset, ElementName=PART_SubMenuScrollViewer}" />
							<Setter Property="Canvas.Left" TargetName="OverlayRect"
									Value="{Binding HorizontalOffset, ElementName=PART_SubMenuScrollViewer}" />-->
						</Trigger>
						<DataTrigger Binding="{Binding IsInQuickAccessToolBar, RelativeSource={RelativeSource Self}}"
								Value="True">
							<Setter Property="Height" TargetName="PART_ToggleButton" Value="Auto" />
						</DataTrigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="TextElement.Foreground" TargetName="MainGrid" Value="#FF9E9E9E" />
						</Trigger>
						<Trigger Property="HasGallery" Value="True">
							<Setter Property="HorizontalScrollBarVisibility" TargetName="PART_SubMenuScrollViewer"
									Value="Disabled" />
							<Setter Property="VerticalScrollBarVisibility" TargetName="PART_SubMenuScrollViewer"
									Value="Disabled" />
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="CanUserResizeHorizontally" Value="True" />
								<Condition Property="CanUserResizeVertically" Value="True" />
							</MultiTrigger.Conditions>
							<Setter Property="Visibility" TargetName="ResizeControl" Value="Visible" />
						</MultiTrigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="CanUserResizeHorizontally" Value="False" />
								<Condition Property="CanUserResizeVertically" Value="True" />
							</MultiTrigger.Conditions>
							<Setter Property="Visibility" TargetName="ResizeControl" Value="Visible" />
							<Setter Property="Style" TargetName="PART_ResizeThumb">
								<Setter.Value>
									<Style TargetType="{x:Type Thumb}">
										<Setter Property="Height" Value="11" />
										<Setter Property="Cursor" Value="SizeNS" />
										<Setter Property="Template">
											<Setter.Value>
												<ControlTemplate TargetType="{x:Type Thumb}">
													<Border Background="Transparent">
														<Path HorizontalAlignment="Center" Margin="0,0,2,2"
																VerticalAlignment="Bottom">
															<Path.Data>
																<RectangleGeometry Rect="0,0,11,3" />
															</Path.Data>
															<Path.Fill>
																<DrawingBrush TileMode="Tile" Viewbox="0,0,3,3"
																		Viewport="0,0,3,3" ViewportUnits="Absolute"
																		ViewboxUnits="Absolute">
																	<DrawingBrush.Drawing>
																		<DrawingGroup>
																			<GeometryDrawing Brush="#FF6C747D"
																					Geometry="M0,0L2,0 2,2 0,2z" />
																		</DrawingGroup>
																	</DrawingBrush.Drawing>
																</DrawingBrush>
															</Path.Fill>
														</Path>
													</Border>
												</ControlTemplate>
											</Setter.Value>
										</Setter>
									</Style>
								</Setter.Value>
							</Setter>
						</MultiTrigger>
						<Trigger Property="IsDropDownPositionedAbove" Value="True">
							<Setter Property="Grid.Row" TargetName="ResizeControl" Value="0" />
							<Setter Property="BorderThickness" TargetName="ResizeControl" Value="0,0,0,1" />
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsDropDownPositionedAbove" Value="True" />
								<Condition Property="CanUserResizeHorizontally" Value="True" />
								<Condition Property="CanUserResizeVertically" Value="True" />
							</MultiTrigger.Conditions>
							<Setter Property="Style" TargetName="PART_ResizeThumb">
								<Setter.Value>
									<Style TargetType="{x:Type Thumb}">
										<Setter Property="Width" Value="11" />
										<Setter Property="Height" Value="11" />
										<Setter Property="VerticalAlignment" Value="Top" />
										<Setter Property="HorizontalAlignment" Value="Right" />
										<Setter Property="Cursor" Value="SizeNESW" />
										<Setter Property="Template">
											<Setter.Value>
												<ControlTemplate TargetType="{x:Type Thumb}">
													<Border Background="Transparent">
														<Path Data="M0,0L0,3 3,3 3,6 6,6 6,9 9,9 9,11 11,11 11,0z"
																Margin="0,2,2,0">
															<Path.Fill>
																<DrawingBrush TileMode="Tile" Viewbox="0,0,3,3"
																		Viewport="0,0,3,3" ViewportUnits="Absolute"
																		ViewboxUnits="Absolute">
																	<DrawingBrush.Drawing>
																		<DrawingGroup>
																			<GeometryDrawing Brush="#FF6C747D"
																					Geometry="M0,0L2,0 2,2 0,2z" />
																		</DrawingGroup>
																	</DrawingBrush.Drawing>
																</DrawingBrush>
															</Path.Fill>
														</Path>
													</Border>
												</ControlTemplate>
											</Setter.Value>
										</Setter>
										<Style.Triggers>
											<Trigger Property="FlowDirection" Value="RightToLeft">
												<Setter Property="Cursor" Value="SizeNWSE" />
											</Trigger>
										</Style.Triggers>
									</Style>
								</Setter.Value>
							</Setter>
						</MultiTrigger>
						<Trigger Property="HasItems" Value="False">
							<Setter Property="Ribbon:RibbonTwoLineText.PathData" TargetName="PART_ToggleButton"
									Value="{x:Null}" />
						</Trigger>
						<Trigger Property="IsOpen" SourceName="PART_Popup" Value="False">
							<Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>